# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Tom Richards <tom@tomrichards.net>
# Contributor: TingPing <tingping@tingping.se>
# Contributor: Omar Pakker <omar.pakker@oracle.com>

pkgname=retro-gtk
pkgver=1.0.2
pkgrel=3
pkgdesc='Toolkit to write GTK based Libretro frontends'
arch=('loong64' 'x86_64')
url='https://gnome.pages.gitlab.gnome.org/retro-gtk/'
license=('GPL3')
depends=('gcc-libs' 'gdk-pixbuf2' 'glib2' 'glibc' 'gtk3' 'libepoxy' 'libpulse' 'libsamplerate')
makedepends=('gobject-introspection' 'meson' 'vala')
source=("https://download.gnome.org/sources/$pkgname/${pkgver%.*}/$pkgname-$pkgver.tar.xz"
        'retro-gtk-remove-unknown-arguments.patch::https://gitlab.gnome.org/GNOME/retro-gtk/-/commit/8016c10e7216394bc66281f2d9be740140b6fad6.patch')
sha256sums=('7118b0b5f9c1f2f0bc742faf8689eb48b44833efada0f6dbce990ec9783bcbd2'
            '5a165f0e63fb9f8e10222c60d8c21068b3c2ebf4080dc822ddc65d649dcc39e0')

prepare() {
  # https://gitlab.gnome.org/GNOME/retro-gtk/-/commit/8016c10e7216394bc66281f2d9be740140b6fad6
  patch -d $pkgname-$pkgver -Np1 -i ../retro-gtk-remove-unknown-arguments.patch
}

build() {
  arch-meson $pkgname-$pkgver build \
    -D build-doc=true \
    -D install-doc=true
  meson compile -C build
}

check() {
  # Tests try to run the installed /usr/lib/retro-runner

  #dbus-run-session xvfb-run \
  #  -s '-screen 0 1920x1080x24 -nolisten local' \
  #  meson test -C build --print-errorlogs
  :
}

package() {
  meson install -C build --destdir "$pkgdir"
}
